package com.ydy.ewallet.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * FileName: MybatisPlusConfig.java
 * Description: MybatisPlus配置类
 *
 * @author XMiker
 * @date 2018/11/15 10:14
 * @since JDK 1.8
 */
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {

    /**
     * 相当于顶部的：
     * {@code @MapperScan("com.baomidou.springboot.mapper*")} 这个注解，作用相当于下面的@Bean MapperScannerConfigurer，2者配置1份即可
     * 这里可以扩展，比如使用配置文件来配置扫描Mapper的路径
     */
    @Bean
    public static MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
        scannerConfigurer.setBasePackage("com.ydy.ewallet.mapper");
        return scannerConfigurer;
    }

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

}
